<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .show {
            width: 200px;
            height: 200px;
            background-color: rebeccapurple;
        }

        .hide {
            width: 200px;
            height: 200px;
            background-color: black;
        }
    </style>
</head>

<body>
    <div id="div">
        {{msg+1}}
        <div>
            <!--双向数据绑定: 从状态到视图，  从视图到状态 -->
            <!-- 修饰符
                v-model.number:将输入变为数字
                v-model.trim:去除两端的空格
                v-model.lazy:input变为change（失去焦点触发）
            -->
            v-model:<input type="text" v-model.number.trim.lazy="msg">
        </div>
        <div>
            <!-- 从视图到状态: 事件对象.target -->
            v-model原理</v-><input type="text" :value="msg" @change="onInput">
        </div>

    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const app = Vue.createApp({
            data: function () {
                return {
                    msg: '1'
                }
            },
            methods: {
                onInput(e) {
                    console.log(e);
                    this.msg = e.target.value;
                }
            },
        }).mount('#div');
    </script>

</body>

</html>